Creating Custom Components

Back to Contents

The simulator allows, through an XML-based file format, for custom components to be defined as subcircuits of other, fundamental, components. Custom graphics, if required for custom component packages, can also be created using a syntax based upon the WPF Path Markup Syntax (see Microsoft's reference.) This section is intended primarily for "power users", so some basic familiarity with XML syntax is assumed.

Component Data Files

Files containing component models are located in the res/models/ folder in the folder where the program was installed to. Each file contains model for a different type of component:

A sample entry in one of these files is that for the 555 Timer, which is included below

<model name="555 Timer" category="Analog" footprint="DIP8">
<data>RES {r}.R1 {8} {5}  res=5000
RES {r}.R2 {5} {r}.VL res=5000
RES {r}.R3 {r}.VL {1} res=5000
OPAMP {r}.U1 {6} {5} {r}.UC {1} {8}
OPAMP {r}.U2 {r}.VL {2} {r}.LC {1} {8}
LOGIC_NOT {r}.U3 {4} {r}.R_INV {1} {8}
LOGIC_OR {r}.U4 {r}.R_INV {r}.UC {r}.RES {1} {8}
LOGIC_RS_FLIP_FLOP {r}.U5 {r}.RES {r}.LC {3} {r}.QB {1} {8}
RES {r}.R4 {r}.QB {r}.DC res=1000
BJT {r}.Q1 {7} {r}.DC {1} type=npn is=19e-15 bf=150 br=7.5 rb=50 re=0.4 rc=0.3</data>
<label pin="1" name="Ground"/>
<label pin="2" name="Trigger"/>
<label pin="3" name="Output"/>
<label pin="4" name="Reset"/>
<label pin="5" name="Control Voltage"/>
<label pin="6" name="Threshold"/>
<label pin="7" name="Discharge"/>
<label pin="8" name="Supply"/>
</model>

Firstly, various pieces of information are specified about the component in the model tag parameters:

Inside the <data> tags contain the subcircuit data itself, which is described in the next section.

Each label tag specifies a user friendly name for a pin, with pin being the pin number and name being the label to display.

Defining Components

An example of a component defined as a subcircuit is a 555 Timer. The subcircuit data for this component is shown in the above section - refer to the content inside the <data> tags

Each line defines a component. Component definitions consist of the following elements, in this order:

The following component types are supported by the simulator

The pin ordering for common components (where pin ordering is important) are as follows:

The following parameters are supported: (note that all parameters are optional, although many parameters are effectively required)

Note that {r} is replaced with the unique (in the circuit) name of the component - for a custom IC this would be in the form ICn, where n is an integer, and {n} (where n is an integer between 1 and the number of pins) is replaced with the name of the net connected to pin n. In order to ensure multiple instances of the same subcircuit can be placed, all internal net and component names should be prefixed with "{r}.".

Defining Component Footprints

If you need to add a component which has a package type not included in the default set of footprints, you will need to add an entry to the footprints.xml file. An example entry in this file, for the DIP8 package, is:

<footprint name="DIP8">
<!-- PINS -->
<pin  number="1" x="0" y="3"/>
<pin  number="2" x="1" y="3"/>
<pin  number="3" x="2" y="3"/>
<pin  number="4" x="3" y="3"/>
<pin  number="5" x="3" y="0"/>
<pin  number="6" x="2" y="0"/>
<pin  number="7" x="1" y="0"/>
<pin  number="8" x="0" y="0"/>

<path name="pin8" fillcolour="Gray" linecolour="Gray">M -0.2, -0.2 h 0.4 v 0.6 h -0.4 v -0.6</path>
<path name="pin7" fillcolour="Gray" linecolour="Gray">M 0.8, -0.2 h 0.4 v 0.6 h -0.4 v -0.6</path>
<path name="pin6" fillcolour="Gray" linecolour="Gray">M 1.8, -0.2 h 0.4 v 0.6 h -0.4 v -0.6</path>
<path name="pin5" fillcolour="Gray" linecolour="Gray">M 2.8, -0.2 h 0.4 v 0.6 h -0.4 v -0.6</path>
<path name="pin1" fillcolour="Gray" linecolour="Gray">M -0.2, 2.6 h 0.4 v 0.6 h -0.4 v -0.6</path>
<path name="pin2" fillcolour="Gray" linecolour="Gray">M 0.8, 2.6 h 0.4 v 0.6 h -0.4 v -0.6</path>
<path name="pin3" fillcolour="Gray" linecolour="Gray">M 1.8, 2.6 h 0.4 v 0.6 h -0.4 v -0.6</path>
<path name="pin4" fillcolour="Gray" linecolour="Gray">M 2.8, 2.6 h 0.4 v 0.6 h -0.4 v -0.6</path>
<!-- CHIP BODY -->
<path fillcolour="Black" linecolour="Black">M -0.4, 0.4 H 3.4 V 2.6 H -0.4 V 0.4</path>
<!-- CHIP NOTCH -->
<path fillcolour="DarkGray" linecolour="DarkGray">M -0.4, 1.2 H 0 V 1.8 H -0.4 V 1.2</path>

<text name="_Model" X="0.5" Y="0.9" size="1" colour="White">DIP8</text>
 
</footprint>

All locations and sizes inside the footprint definition - in pin, path and text elements - are given in a format such at (0, 0) is the 'origin' of the component and each unit represents the space between two adjacent holes.

pin elements specify the location of a pin. It takes three attributes: the pin number, and the x and y locations of that pin.

path elements specify graphics using the WPF Path Markup Syntax. The name attribute gives the name of the path. A name of the type pinn sets that path to be a pin, where n is the pin number. This enables the tooltips that display pin names, voltages and currents.

fillcolour sets the colour with which closed parts of the path are filled. linecolour sets the colour of the lines. Optionally, the thickness attribute can be set to change the line thickness. Inside the path element is the path data itself - see the Microsoft reference linked above.

text elements can be used to add text to the component. The name attribute can be used to make 'special' text elements - setting it to _Model makes it display the model name, and _Value makes it display the component value. X and Y set the position of the text, size sets the font size and colour the colour of the text. Optionally, the font attribute can be used to specify the name of a font to use when displaying the text. Inside the element is the default text to display. All dimensions and positions use the units described above.

Back to Contents